/**
 * Created by TRwin7SP1 on 2016/8/15.
 */
angular.module('inspinia')
  .controller('treatmentCtrl',function ($scope,toaster,SweetAlert) {
    $scope.times = [];
    var newDate = new Date();
    $scope.treatment = {
      date:newDate.getFullYear()+"-"+(newDate.getMonth()+1)+"-"+newDate.getDay(),
      remarks:''
    };

    $scope.init = function(){

/*      var _times = window.localStorage.getItem('times');
      //初始化治疗次数列表
      for(var i=1 ; i <= 20 ; i++){
        var _obj = {
          id:i,
          txt:"第" + i +"次治疗"
        }
        $scope.times.push(_obj);
      }*/

      $scope.patient = JSON.parse(localStorage.getItem('treatObj'));
    };
    $scope.init();

    $scope.save = function(){
      swal({
          title: "治疗",
          text: "治疗操作是否已完成",
          type: "warning",
          showCancelButton: true,
          confirmButtonColor: "#DD6B55",
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          closeOnConfirm: true,
          closeOnCancel: true
        },
        function(isConfirm){
          if (isConfirm) {
/*            if($scope.patient.treatTimes<$scope.patient.payTimes){
              $scope.patient.treatTimes +=1;
              $scope.$apply();//解决第一次点击完成按钮时，table没有改变问题
            }*/
            $scope.patient.treatTimes +=1;
            window.localStorage.setItem('treatObj',JSON.stringify( $scope.patient));
            window.location.href="#/index/treatRecord";
          }
        });

    };
  });
